package com.chaowen.util;

import android.content.Context;
import android.content.SharedPreferences;
import java.util.HashMap;

public class PreferenceHelper
{
  public static final String PASSWORD = "password";
  public static final String REMEMBER = "remember";
  public static final String USERNAME = "username";
  private final String PREFERS_FILE_NAME = "csunet";
  private static final String ISLOGIN = "isLogin";
  private Context context;

  public PreferenceHelper(Context paramContext)
  {
    this.context = paramContext;
  }

  public HashMap<String, Object> getPreferences()
  {
    HashMap localHashMap = new HashMap();
    SharedPreferences localSharedPreferences = this.context.getSharedPreferences("csunet", 0);
    localHashMap.put("username", localSharedPreferences.getString("username", ""));
    localHashMap.put("password", localSharedPreferences.getString("password", ""));
    localHashMap.put("isRemembered", Boolean.valueOf(localSharedPreferences.getBoolean("isRemembered", false)));
//    localHashMap.put("isLogin", Boolean.valueOf(localSharedPreferences.getBoolean("isLogin", false)));
    return localHashMap;
  }

  public void save(String username, String password, boolean isRemembered)
  {
    SharedPreferences.Editor localEditor = this.context.getSharedPreferences("csunet", 0).edit();
    localEditor.putString("username", username);
    localEditor.putString("password", password);
    localEditor.putBoolean("isRemembered", isRemembered);
//    localEditor.putBoolean("isLogin", isLogin);
    localEditor.commit();
  }
  
//  public void saveLogin(boolean isLogin)
//  {
//    SharedPreferences.Editor localEditor = this.context.getSharedPreferences("csunet", 0).edit();
//    localEditor.putBoolean("isLogin", isLogin);
//    localEditor.commit();
//  }
  
}